﻿using System;
using System.Reflection;
using System.Linq;
using System.Collections.Generic;

namespace Transportr
{
    public static class Icon
    {
        public static string Vehicle(ServiceModel.VehicleType type)
        {
            switch (type)
            {
                case ServiceModel.VehicleType.LocalBus:
                case ServiceModel.VehicleType.NightBus:
                    return "../Images/icon.90.bus.png";
                case ServiceModel.VehicleType.Metro:
                    return "../Images/icon.90.metro.png";
                case ServiceModel.VehicleType.Tram:
                    return "../Images/icon.90.villamos.png";
                case ServiceModel.VehicleType.Suburban:
                    return "../Images/icon.90.hev.png";
                case ServiceModel.VehicleType.Trolley:
                    return "../Images/icon.90.troli.png";

                default:
                    return "../Images/icon.90.unknown.png";
            }
        }
    }

    public static class Enumerator
    {
        public static string[] GetNames(this Enum e)
        {
            List<string> enumNames = new List<string>();

            foreach (FieldInfo fi in e.GetType().GetFields(BindingFlags.Static | BindingFlags.Public))
            {
                enumNames.Add(fi.Name);
            }

            return enumNames.ToArray<string>();
        }

        public static Array GetValues(this Enum e)
        {
            List<int> enumValues = new List<int>();

            foreach (FieldInfo fi in e.GetType().GetFields(BindingFlags.Static | BindingFlags.Public))
            {
                enumValues.Add((int)Enum.Parse(e.GetType(), fi.Name, false));
            }

            return enumValues.ToArray();
        }
    }
}
